﻿using Share.Services;
using System.Text.Json.Serialization;

namespace Share.APIs;

#region 请求的 biz_content 部份
public class QAccBalV2 : IcbcApiRequest
{
    /// <summary>
    /// 接口地址
    /// </summary>
    internal override string Url => "api/mybank/enterprise/account/qaccbal/V2";

    [JsonPropertyName("trans_code")] public string TransCode => "QACBL";
    [JsonPropertyName("tran_date")] public string TranDate { get; set; } = DateTime.Today.ToString("yyyyMMdd");
    [JsonPropertyName("tran_time")] public string TranTime { get; set; } = DateTime.Now.ToString("HHmmssfff");
    [JsonPropertyName("language")] public string Language { get; set; } = "zh_CN";
    [JsonPropertyName("f_seq_no")] public string FSeqNo { get; set; } = UtilitiesService.GetFSeqNo(); // $"zs{DateTime.Today:yyyyMMdd}{DateTime.Now:HHmmssfff}{Random.Shared.Next()}";
    [JsonPropertyName("account_no")] public string AccountNo { get; set; } = string.Empty;
    [JsonPropertyName("currency")] public string Currency { get; set; } = string.Empty;
    [JsonPropertyName("sub_no")] public string SubNo { get; set; } = string.Empty;
    [JsonPropertyName("next_tag")] public string NextTag { get; set; } = string.Empty;

}
#endregion

#region 响应的 response_biz_content 部份
public class QAccBalV2Response : IcbcApiResponse
{
    [JsonPropertyName("account_no")] public string AccountNo { get; set; } = string.Empty;
    [JsonPropertyName("currency")] public string Currency { get; set; } = string.Empty;
    [JsonPropertyName("sub_no")] public string SubNo { get; set; } = string.Empty;
    [JsonPropertyName("next_tag")] public string NextTag { get; set; } = string.Empty;
    [JsonPropertyName("rd")] public List<QAccBalV2ResponseRd> Rd { get; set; } = new();
}

public class QAccBalV2ResponseRd
{
    [JsonPropertyName("account_name")] public string AccountName { get; set; } = string.Empty;
    [JsonPropertyName("sub_no")] public string SubNo { get; set; } = string.Empty;
    [JsonPropertyName("currency")] public string Currency { get; set; } = string.Empty;
    [JsonPropertyName("cash_exf")] public string CashExf { get; set; } = string.Empty;
    [JsonPropertyName("account_property")] public string AccountProperty { get; set; } = string.Empty;
    [JsonPropertyName("yesterday_balance")] public decimal YesterdayBalance { get; set; }
    [JsonPropertyName("balance")] public decimal Balance { get; set; }
    [JsonPropertyName("usable_balance")] public decimal UsableBalance { get; set; }
    [JsonPropertyName("frozen_amt")] public decimal FrozenAmt { get; set; }
    [JsonPropertyName("query_time")] public string QueryTime { get; set; } = string.Empty;
    [JsonPropertyName("hold_amt")] public decimal HoldAmt { get; set; }
    [JsonPropertyName("last_intr_date")] public string LastIntrDate { get; set; } = string.Empty;
    [JsonPropertyName("last_tran_date")] public string LastTranDate { get; set; } = string.Empty;
}
#endregion

#region 返回
/*
 {"response_biz_content":
{"return_msg":"集团无此账号","msg_id":"cs2025010710375587144469974","return_code":10660041},
"sign":"MEUCIQC0GM9QdMj7lR+7zy9vXWrsBZKuvyYGzqqY5MvxdpHqlAIgBX3jh9RebmkLNswBASm2bDwpsgZH+TAiNChJafYX5k8=","icbc_ca":"MIICYTCCAgWgAwIBAgIFEGBBSCMwDAYIKoEcz1UBg3UFADBcMQswCQYDVQQGEwJDTjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRswGQYDVQQDDBJDRkNBIFRFU1QgU00yIE9DQTEwHhcNMjQxMjA0MDEzODQ5WhcNMjUxMjA0MDEzODQ5WjBjMQswCQYDVQQGEwJDTjENMAsGA1UECgwET0NBMTEPMA0GA1UECwwGQ0NGQ0NCMRkwFwYDVQQLDBBPcmdhbml6YXRpb25hbC0xMRkwFwYDVQQDDBB0ZXN0MTBCMTAwMDc3NDA3MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEe0L4n3HNwOXSLHrOW2d6mGW2J7naWk5Ty6VLvzyBkVO/RD1l4MHmwdTbuLvIyAmC+QQu9UnZDEr5w6wMqIo9/qOBqjCBpzAfBgNVHSMEGDAWgBRr/hjaj0I6prhtsy6Igzo0osEw4TA5BgNVHR8EMjAwMC6gLKAqhihodHRwOi8vdWNybC5jZmNhLmNvbS5jbi9TTTIvY3JsNTQyODQuY3JsMAsGA1UdDwQEAwID6DAdBgNVHQ4EFgQU0t7MWcePZGoHTr+QoPAXESdWXngwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMEMAwGCCqBHM9VAYN1BQADSAAwRQIgYhe3nBpBrISK7OboGmUOLZ7UQLPkG0DPrLKNdrHOC5ACIQCoq67JOryBHbdbKGnIT9adii4lA6ugr91iiU6dPRLZnA=="
}
 */
#endregion